import type { PutDto, PutRes, PutMutiDto, PutMutiRes, DisableDto, DisableRes } from "~/rest";
import { WithPasterList } from "~/view.with";

import { Gateway, getGateway } from "@/droplet-bus/core.define";
import { RiverTonGateway } from "@/river-ton/core.define";
import { TonTplGroup, TonTpl } from "@/river-ton/schema.tpl";
import { PageResult } from "~/search";

/** 商品模板分组 */
export const TonTplGroupGateway: Gateway = getGateway(RiverTonGateway, "river_ton_tpl_group");
export type putTonTplGroupDto = PutMutiDto<TonTplGroup>;
export type deleteTonTplGroupDto = DisableDto;

export interface TonTplGroupInterfaceWithPrimary<T> {
  get(dto: T): Promise<PageResult<TonTplGroup>>;
  put(dto: T & putTonTplGroupDto): Promise<PutMutiRes<TonTplGroup>>;
  disable(dto: T & deleteTonTplGroupDto): Promise<DisableRes>;
}

/** 商品模板 */
export const TonTplGateway: Gateway = getGateway(RiverTonGateway, "river_ton_tpl");
export type postTonTplDto = PutMutiDto<WithPasterList & TonTpl> & { groupId: TonTplGroup["id"] };
export type putTonTplDto = PutDto<TonTpl>;
export type deleteTonTplDto = DisableDto;
export interface TonTplInterfaceWithDerive<T> {
  post(dto: T & postTonTplDto): Promise<PutMutiRes<TonTpl>>;
  put(dto: T & putTonTplDto): Promise<PutRes<TonTpl>>;
  delete(dto: T & deleteTonTplDto): Promise<DisableRes>;
}
